package com.xzx.study;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListViewSimpleAdapterActivity extends AppCompatActivity {

    private ListView listView2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view_simple_adapter);

        listView2 = findViewById(R.id.listView2);
        List<Map<String, Object>> data = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("icon", R.drawable.f1);
        item.put("name", "name---1");
        item.put("content", "content---1");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f2);
        item.put("name", "name---2");
        item.put("content", "content---2");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f3);
        item.put("name", "name---3");
        item.put("content", "content---3");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f4);
        item.put("name", "name---4");
        item.put("content", "content---4");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f5);
        item.put("name", "name---5");
        item.put("content", "content---5");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f6);
        item.put("name", "name---6");
        item.put("content", "content---6");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f7);
        item.put("name", "name---7");
        item.put("content", "content---7");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f8);
        item.put("name", "name---8");
        item.put("content", "content---8");
        data.add(item);

        item = new HashMap<>();
        item.put("icon", R.drawable.f9);
        item.put("name", "name---9");
        item.put("content", "content---9");
        data.add(item);

        listView2.setAdapter(new SimpleAdapter(this, data, R.layout.item_list_view_simple_adapter,
                                               new String[]{"icon", "name", "content"}, new int[]{
                R.id.simple_adapter_icon, R.id.simple_adapter_name, R.id.simple_adapter_content}));
    }
}
